package online.inote.modules.article.controller;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import online.inote.common.annotation.AutoValid;
import online.inote.common.annotation.AutoValids;
import online.inote.common.utils.ResultFactory;
import online.inote.common.utils.ResultFactory.ResultEnum;
import online.inote.modules.article.entity.ArticleContentEntity;
import online.inote.modules.article.entity.ArticleEntity;

/**
 * <p>
 * Desc: 
 * </p>
 *
 * @author XQF SUI
 * @created 2018年9月10日 下午8:08:13
 * @version 1.0
 */
@RestController
@RequestMapping(value = "article")
public class ArticleController {

	private Logger logger = LoggerFactory.getLogger(getClass());
	
	/**
	 * <p>
	 * Desc: 
	 * </p>
	 *
	 * @author XQF SUI
	 * @created 2018年9月10日 下午8:44:13
	 * @param jsonInfo 
	 * @return
	 * @测试参数 
	 * 		不通过:{"article" : {"id" : "1"}, "content" : {"id" : "1"} }
	 * 		    通过:{"article" : {"id" : "1", "title" : "aa"}, "content" : {"id" : "1", "content" : "bb"} }
	 */
	@AutoValids({ 
		@AutoValid(entity = ArticleEntity.class, key = "article"),
		@AutoValid(entity = ArticleContentEntity.class, key = "content")
	})
	@PostMapping(value = "save")
	public Map<String, Object> save(@RequestBody String jsonInfo) {
		logger.info("参数:{}", jsonInfo);
		logger.info("验证通过");
		return ResultFactory.createResultMap(ResultEnum.SUCCESS);
	}
}